1. Field of the Invention
The invention relates in general to a loop detection method and a network device applying the same, in which the determination of the existence of the loop is based on whether the source address moves.
2. Description of the Related Art
Ethernet network, the most commonly used local area network (LAN), is used for linking personal computer (PC) to a local area network (LAN). In the Ethernet network, data is transmitted in packet. The switch is the most commonly used bridge in the local area network and there are other bridges such as router.
A switch has many ports linked to a PC, a notebook computer or other bridges. After one port of the switch receives a packet, the switch selects appropriate destination port according to the destination address of the packet and then transmits the packet to the destination port.
Low-level switch, usually not supporting the network management function, does not always have a central processing unit (CPU) for computation. If the low-level switch is not equipped with CPU, the packet is processed by an application specified integrated circuit (ASIC) without computation ability. Therefore, the low-level switch, though having the advantage of low cost, is not adapted to complicated communication protocols.
Broadcast is a transmission method for Ethernet network. A packet with a specific destination address is regarded as a broadcast packet. When the switch receives the broadcast packet, the switch transmits the broadcast packet to each port. In a large-scaled local area network, the loop may be formed between two or more bridges and there may have more than two paths existing in the loop. The broadcast packet may be repeatedly transmitted or forwarded within the loop, not only occupying the bandwidth of the network and consuming the resources of the network device but also deteriorating the efficiency of the network.
In detail, when a loop occurs in the network, the packet will be endlessly transmitted within the loop, greatly deteriorating transmission efficiency. The packet occupies a fixed memory space in a switch. Under normal circumstance, after a packet is transmitted, the switch can release the memory space occupied by the packet. However, with the existence of the loop, after a broadcast packet is transmitted, the switch may immediately receive the broadcast packet which has just been transmitted, and further store the broadcast packet in the memory and waste memory space. If there is a large number of broadcast packets in the loop, all the available memory space in the switch will almost be used up, leading to packet loss (data loss) or even causing the network to shut down.
Referring to FIG. 1A and FIG. 1B, two kinds of loops formed in LAN are respectively shown. In FIG. 1A, the PCs 105 and 115 transmit packets to each other through the switches 110 and 120. As indicated in FIG. 1A, the packets transmitted from the switch 110 may be sent back by the switch 130, hence forming a loop.
In FIG. 1B, the PCs 105 and 115 transmit packets to each other through the switches 110, 120 and 130. As indicated in FIG. 1B, the packet transmitted from the switch 110 may be sent back by the switches 130 and 140, hence forming a loop. The loop illustrated in FIG. 1B is referred as self-loop as for the switch 110.
Currently, several technologies are already provided to resolve problems caused by the loop. In a first technology, conformed to IEEE 802.1 spanning tree protocol, according to the spanning tree protocol, when a loop occurs, some links on the loop will be cut off (for example, a link is broken by disabling port(s) of the switch), so as to break the loop. However, it is more costive to support the spanning tree protocol by hardware. If the spanning tree protocol is supported by software, then the switch needs to have a CPU. But low-level switch does not always have a CPU, the spanning tree protocol is not very adaptable to the low-level switch.
The second technology is achieved by simplifying the spanning tree protocol for low cost. The second technology also breaks a loop by disabling port(s) of the switch. However, after a loop is broken, the second technology is unable to restore (i.e. enable) the disabled ports. This will lead to a cut-off of LAN and incapacitates packet transmission.
Embodiments of the invention provide a low-cost loop detection method, adaptable to low-level, middle-level or high-level network device.